from utils.ssh import secure_crt
import logging
logging.basicConfig(level=logging.INFO)

crt = secure_crt('192.168.89.128', 'root', 'yuchen123456')
flag, res = crt.exec_cmd('docker --version')
if not flag:
    #crt.yum('yum update -y')
    crt.exec_cmd('systemctl stop firewalld')
    crt.exec_cmd('systemctl disable firewalld')
    crt.exec_cmd('mkdir -p /root/docker')
    crt.copy_file('File/docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm',
                  '/root/docker/docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm')
    crt.copy_file('File/docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm',
                  '/root/docker/docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm')
    crt.yum('cd /root/docker && yum -y install *')
    crt.yum('systemctl start docker')
    crt.yum('systemctl enable docker')
    logging.basicConfig(level=logging.INFO)
print(crt.yum('docker run hello-world'))
crt.close_all()


